package com.example.demo.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.Result;
import com.example.demo.entity.WebPage1Block;
import com.example.demo.entity.WebPage1User;
import com.example.demo.mapper.Page1BlockControllerMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/page1block")

public class Page1BlockController {
        @Resource
        Page1BlockControllerMapper page1BlockControllerMapper;

        @PostMapping
        public Result<?> save(@RequestBody WebPage1Block webPage1Block){
            page1BlockControllerMapper.insert(webPage1Block);
            return Result.success();
        }
        @PutMapping
        public Result<?> update(@RequestBody  WebPage1Block webPage1Block){
            page1BlockControllerMapper.updateById(webPage1Block);
            return Result.success();
        }
        @GetMapping
        public List<WebPage1Block> selectList(@RequestParam int searchId){
            LambdaQueryWrapper<WebPage1Block>wrapper= Wrappers.<WebPage1Block>lambdaQuery();
            wrapper.eq(WebPage1Block::getPageId,searchId);
            return page1BlockControllerMapper.selectList(wrapper);
        }
    @DeleteMapping("/{id}")
    public Result<?> update (@PathVariable Long id){
        page1BlockControllerMapper.deleteById(id);
        return Result.success();
    }
}
